# 获取配置文件
import os

import yaml


class Config:
    # 获取当前文件的目录
    current_dir = os.path.dirname(os.path.abspath(__file__))

    # 获取项目根目录
    project_root = os.path.abspath(os.path.join(current_dir, '..'))

    # 构建 config.yaml 文件的路径
    config_path = os.path.join(project_root, 'config.yaml')
    # print(config_path)

    # 读取 YAML 配置文件
    with open(config_path, 'r', encoding='utf-8') as file:
        config = yaml.safe_load(file)

    # 读取配置项
    default_models = config['default']['models']

    model_name = config[default_models]['model_name']
    api_key = config[default_models]['api_key']
    top_p = config[default_models]['top_p']
    temperature = config[default_models]['temperature']
    max_tokens = config[default_models]['max_tokens']
    if default_models == 'OPENAI':
        model_path = config[default_models]['model_path']

    # 读取终端配置
    terminal_config = config['Terminal']
    terminal_font = terminal_config['TerminalFont']
    render_text = terminal_config['renderText']
    render_text_color = terminal_config['renderTextColor']
